package com.techblor.wechat.library.util;

import java.util.*;

/**
 * 签名工具
 */
public class SignUtil {

    /**
     * 创建签名
     *
     * @param params
     * @return
     */
    public static String createSignature(SortedMap<String, Object> params) {
        StringBuilder builder = new StringBuilder();
        Set<String> keySet = params.keySet();
        Iterator<String> iterator = keySet.iterator();
        while (iterator.hasNext()) {
            String key = iterator.next();
            Object value = params.get(key);

            builder.append(key).append("=").append(value);

            if (iterator.hasNext()) {
                builder.append("&");
            }
        }

        return builder.toString();
    }
}
